package org.deng.vertx.web.model;

import lombok.Data;

/**
 * @Author: DengLibin
 * @Date: Create in 2022-04-29 17:16:44
 * @Description: 异步结果
 */
@Data
public class AsResult<T>{
    //状态码 0:成功 1:失败
    private Integer code;
    private String msg;
    private T data;

    private AsResult(){}

    
  
    /**
     * 成功
     * @param <D>
     * @param d
     * @return
     */
    public static <D>AsResult<D> success(D d){
        AsResult<D> ar = new AsResult<>();
        ar.setCode(0);
        ar.setMsg("OK");
        ar.setData(d);
        return ar; 
    }
    /**
     * 失败
     * @param <D>
     * @param d
     * @return
     */
    public static AsResult<Object> fail(String msg){
        AsResult<Object> ar = new AsResult<>();
        ar.setCode(1);
        ar.setMsg(msg);
        return ar; 
    }
}
